package com.acme.bankapp.networking.server;


import com.acme.bankapp.networking.Connection;

import java.io.IOException;

public class BankServerSkeleton implements AutoCloseable{
    private Connection connection;

    public BankServerSkeleton(Connection connection) {
        this.connection = connection;
    }

    public void onConnect() throws IOException {
        System.out.println("Connection received from "
                + connection.getRequestSocket().getInetAddress().getHostName());
        sendMessage("Connection successfully");
    }

    public String receiveMessage() throws IOException, ClassNotFoundException {
        return (String) connection.read();
    }

    public void sendMessage(Object message) throws IOException {
        connection.write(message);
    }

    @Override
    public void close(){
    }
}
